home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************
- *
- * Copyright © 1990 Apple Computer, Inc. All rights reserved.
- *
- ************************************************************************/
-
- #include <stdio.h>
- #include <Types.h>
- #include <ToolUtils.h>
- #include <Quickdraw.h>
- #include <Files.h>
- #include <Memory.h>
-
- #define ISO
-
- #include "HighSierra.h"
- #include "BuildISO.h"
-
- #include "i_o.proto.h"
- #include "Support.proto.h"
- #include "ErrorMsg.proto.h"
-
-
- /************************************************************************
- *
- * Function: isoOpen
- *
- * Purpose: Open the driver for i/o
- *
- * Returns: OSErr
- *
- * Side Effects: fills *RefNum with valid reference number for driver.
- *
- * Description: Issue Mac OS PBOpen call to open the driver. We
- * can use the returned reference number to access the
- * driver for raw i/o.
- *
- *
- ************************************************************************/
- OSErr
- isoOpen(StringPtr fn, short *RefNum)
- {
- ParamBlockRec pb;
- OSErr result;
-
- pb.ioParam.ioNamePtr = fn;
- pb.ioParam.ioCompletion = 0;
- pb.ioParam.ioPermssn = fsRdPerm;
- result = PBOpen(&pb, false);
- *RefNum = pb.ioParam.ioRefNum;
-
- return result;
- }
-
- /************************************************************************
- *
- * Function: isoRead
- *
- * Purpose: read from the driver
- *
- * Returns: OSErr
- *
- * Side Effects: fills dest with contents for 'count' bytes.
- *
- * Description: do a call to the Mac CD driver to read a specified
- * number of bytes starting at 'offset'. The number of
- * bytes must be a multiple of 512, or this call won't
- * work (the driver returns an error)
- *
- ************************************************************************/
- OSErr
- isoRead(short referenceNumber, Ptr dest, long count, long offset)
- {
- OSErr result;
- ParamBlockRec io;
-
- ClearOut((char *)&io, sizeof(io));
- io.ioParam.ioCompletion = NULL;
- io.ioParam.ioVRefNum = 0;
- io.ioParam.ioRefNum = referenceNumber;
- io.ioParam.ioBuffer = dest;
- io.ioParam.ioReqCount = count;
- io.ioParam.ioPosMode = fsFromStart;
- io.ioParam.ioPosOffset = offset;
- result = PBRead(&io, false);
-
- if (result != noErr)
- ErrorMsg("PBRead failed. ioActCount = %d", io.ioParam.ioActCount);
-
- return result;
- }
-
-
- /************************************************************************
- *
- * Function: isoWrite
- *
- * Purpose: Write to the driver
- *
- * Returns: OSErr
- *
- * Side Effects: none
- *
- * Description: do a call to the Mac CD driver to write a specified
- * number of bytes starting at 'offset'. The number of
- * bytes must be a multiple of 512, or this call won't
- * work (the driver returns an error.)
- *
- ************************************************************************/
- OSErr
- isoWrite(short referenceNumber, Ptr buffer, long count, long offset)
- {
- OSErr result;
- ParamBlockRec io;
-
- ClearOut((char *)&io, sizeof(io));
- io.ioParam.ioCompletion = NULL;
- io.ioParam.ioVRefNum = 1;
- io.ioParam.ioRefNum = referenceNumber;
- io.ioParam.ioBuffer = buffer;
- io.ioParam.ioReqCount = count;
- io.ioParam.ioPosMode = fsFromStart;
- io.ioParam.ioPosOffset = offset;
- result = PBWrite(&io, false);
-
- if (result != noErr)
- ErrorMsg("PBWrite failed. result = %d", result);
-
- return result;
- }
-
-
- /************************************************************************
- *
- * Function: ZeroDisk
- *
- * Purpose: Clean out this disk so it's not HFS anymore
- *
- * Returns: OSErr
- *
- * Side Effects: zero out a lot of disk
- *
- * Description: loop, doing a write of zeros.
- *
- ************************************************************************/
- OSErr
- ZeroDisk(short referenceNumber)
- {
- Ptr noBuffer;
- short i;
- short j;
- OSErr result;
- CursHandle cursor;
-
- noBuffer = NewPtr(CDBLKSIZE);
- if (noBuffer == NULL)
- return (MemError());
- for (i = 0; i < CDBLKSIZE; i++)
- noBuffer[i] = 0;
-
- result = noErr;
-
- cursor = GetCursor(watchCursor);
- if (!cursor)
- SetCursor(*cursor);
- for (i = 0, j = 0; i < 10 && result == noErr; i++, j++)
- result = isoWrite(referenceNumber, noBuffer, (long)CDBLKSIZE, (long) j*CDBLKSIZE);
-
- SetCursor(&qd.arrow);
- DisposPtr(noBuffer);
- return result;
- }
-
- /************************************************************************
- *
- * Function: GetDriveNumber
- *
- * Purpose: Get the driver number
- *
- * Returns: short. The driver number
- *
- * Side Effects: none.
- *
- * Description: PBHGetVInfo() will retrieve the driver
- * number, given the vRefNum associated with a file.
- *
- ************************************************************************/
- short
- GetDriveNumber(short vRefNum)
- {
- HParamBlockRec io;
-
- io.volumeParam.ioCompletion = NULL;
- io.volumeParam.ioNamePtr = NULL;
- io.volumeParam.ioVRefNum = vRefNum;
- io.volumeParam.ioVolIndex = 0;
- PBHGetVInfo(&io, false);
- return io.volumeParam.ioVDrvInfo;
- }
-
-
-